package com.op.teachingliteapp.bean;

import org.json.JSONObject;

import com.op.teachingliteapp.database.table.SeminarTable;

/**
 * Created by Genji on 2015/6/27. Modified by Kevin
 */
public class SeminarBean extends BaseBean {
	private String id;
	private String title;
	private String content;
	private String courseId;
	private String parentId;
	private String isFavourite;
	private String childCount;
	private String likeCount;
	private String imageUrl;
	private UserBean userBean;

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.contentValues.put(SeminarTable.COLUMN_TITLE, title);
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.contentValues.put(SeminarTable.COLUMN_CONTENT, content);
		this.content = content;
	}

	public String getParentId() {
		return parentId;
	}

	public String getIsFavourite() {
		return isFavourite;
	}

	public void setIsFavouritetext(String isFavourite) {
		this.contentValues.put(SeminarTable.COLUMN_IS_FAVOURITE, isFavourite);
		this.isFavourite = isFavourite;
	}

	public String getCourseId() {
		return courseId;
	}

	public void setCourseId(String courseId) {
		this.contentValues.put(SeminarTable.COLUMN_COURSE_ID, courseId);
		this.courseId = courseId;
	}

	public void setParentId(String parentId) {
		this.contentValues.put(SeminarTable.COLUMN_PARENT_ID, parentId);
		this.parentId = parentId;
	}

	public void setIsFavourite(String isFavourite) {
		this.contentValues.put(SeminarTable.COLUMN_IS_FAVOURITE, isFavourite);
		this.isFavourite = isFavourite;
	}

	public String getChildCount() {
		return childCount;
	}

	public void setChildCount(String childCount) {
		this.contentValues.put(SeminarTable.COLUMN_CHILD_COUNT, childCount);
		this.childCount = childCount;
	}

	public String getLikeCount() {
		return likeCount;
	}

	public void setLikeCount(String likeCount) {
		this.contentValues.put(SeminarTable.COLUMN_IS_LIKE_COUNT, likeCount);
		this.likeCount = likeCount;
	}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.contentValues.put(SeminarTable.COLUMN_IMAGE_URL, imageUrl);
		this.imageUrl = imageUrl;
	}
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.contentValues.put(SeminarTable.COLUMN_ID, id);
		this.id = id;
	}

	public void setUserBean(UserBean userBean) {
		this.contentValues.put(SeminarTable.COLUMN_USER_ID, userBean.getId());
		this.contentValues.put(SeminarTable.COLUMN_USER_NAME, userBean.getName());
		this.contentValues.put(SeminarTable.COLUMN_USER_NUMBER, userBean.getNumber());
		this.contentValues.put(SeminarTable.COLUMN_USER_PHONE, userBean.getPhone());
		this.contentValues.put(SeminarTable.COLUMN_USER_EMAIL, userBean.getEmail());
		this.contentValues.put(SeminarTable.COLUMN_USER_IMAGE_URL, userBean.getImageUrl());
		this.contentValues.put(SeminarTable.COLUMN_USER_IS_USING, userBean.getIsUsing());
		this.contentValues.put(SeminarTable.COLUMN_USER_TYPE, userBean.getType());
		this.userBean = userBean;
	}

	public UserBean getUserBean() {
		return userBean;
	}

	@Override
	public void fillAttributeByJson(JSONObject jsonObject) {
		setId(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_ID));
		setCreateTime(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_CREATE_TIME));
		setUpdateTime(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_UPDATE_TIME));
		setTitle(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_TITLE));
		setContent(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_CONTENT));
		setCourseId(getJsonValue(jsonObject, "null", SeminarTable.COLUMN_COURSE_ID));
		setParentId(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_PARENT_ID));
		setIsFavourite(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_IS_FAVOURITE));
		setChildCount(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_CHILD_COUNT));
		setLikeCount(getJsonValue(jsonObject, "null", SeminarTable.COLUMN_IS_LIKE_COUNT));
		setImageUrl(getJsonValue(jsonObject, SeminarTable.TABLE_SEMINAR, SeminarTable.COLUMN_IMAGE_URL));

		// 填充UserBean
		UserBean userBean = new UserBean();
		userBean.fillAttributeByJson(jsonObject);
		setUserBean(userBean);
	}

}
